package kr.hkit.androidproject_caloriecheck.home;

import kr.hkit.androidproject_caloriecheck.R;
import kr.hkit.androidproject_caloriecheck.DAO;
import android.app.Fragment;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;

public class HomeFragment extends Fragment {
	TextView basic;
	TextView eat;
	TextView totalEat;
	TextView exercise;
	ProgressBar mProgBar;
	ProgressBar mProgBar2;
	DAO dao;
	
	int eatKcal;
	Handler mHandler;
	
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View root = inflater.inflate(R.layout.home, container, false);
		dao = DAO.open(getActivity());
		basic = (TextView) root.findViewById(R.id.basic);
		eat = (TextView) root.findViewById(R.id.eat);
		totalEat = (TextView) root.findViewById(R.id.total_eat);
		exercise = (TextView) root.findViewById(R.id.exercise);
		mProgBar = (ProgressBar) root.findViewById(R.id.progressBar1);
		mProgBar2 = (ProgressBar) root.findViewById(R.id.progressBar2);
		
		SharedPreferences pref = getActivity().getSharedPreferences("user", 0);
		int kcal = pref.getInt("kcal", 0);
		basic.setText("권장량 " + String.valueOf(kcal) + "kcal");
		
		pref = getActivity().getSharedPreferences("num", 0);
		int eatSum = pref.getInt("eatSum", 0);
		eat.setText("현재 섭취량 " + String.valueOf(eatSum) + "kcal");
		totalEat.setText("총 섭취량 " + String.valueOf(eatSum) + "kcal");
		
		int exerciseSum = pref.getInt("exerciseSum", 0);
		exercise.setText("현재 운동량 " + String.valueOf(exerciseSum) + "kcal");
		
		eatKcal = pref.getInt("eatKcal", 0);
		
		mProgBar.setMax(kcal);
		
		mHandler = new Handler(){
			public void handleMessage(Message msg) {
				
			}
		};

		
		return root;
	}
	
	class BackThread extends Thread{
		public void run() {
			int temp = 0;
			if(temp != eatKcal){
				
			}
		}
	}
}
